/*
 * Copyright (c) 2018, dreamkaylee@foxmail.com All Rights Reserved.
 */

package com.common.beetl;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.beetl.core.GroupTemplate;
import org.beetl.core.Template;
import org.beetl.ext.web.WebRenderExt;

import com.common.util.ResourceUtil;

/**
 * beetl全局变量扩展
 * 
 * @author limk
 * @date 2018年2月12日 下午6:12:11
 * @version 1.0
 */
public class GlobalExt implements WebRenderExt {

	@Override
	public void modify(Template template, GroupTemplate groupTemplate, HttpServletRequest request,
			HttpServletResponse response) {
		// 系统名称
		template.binding("projectName_CN", ResourceUtil.getConfigByName("projectName_CN"));
		template.binding("projectName_EN", ResourceUtil.getConfigByName("projectName_EN"));
		template.binding("copyright", ResourceUtil.getConfigByName("copyright"));
		template.binding("domainName", ResourceUtil.getConfigByName("domainName"));
		template.binding("author", ResourceUtil.getConfigByName("author"));
		// 扩展shiro标签
		groupTemplate.registerFunctionPackage("shiro", new ShiroExt());
		// 登陆用户信息
		template.binding("userModel", request.getSession().getAttribute("userModel"));
	}
}
